<template>
  <div class="fold_item">
    <div class="operation"  @click="changeIsShow">
      <div>
        <div class="info-text">{{ title }}</div>
        <div class="icon" :class="[!isShow?'rotate':'rotate-go']">
          <img src="../../image/u50.png" alt="">
        </div>
        <div class="add-icon" v-if="isAdd">
          <router-link :to="`/inputInformation/${whereIs}`">
            <img src="../../image/u256.png">
          </router-link>
        </div>
      </div>
    </div>
    <transition name="fade" mode="out-in">
      <div v-show="isShow">
        <slot/>
      </div>
    </transition>
  </div>
</template>

<script>
  export default {
    name: 'folding',
    props: {
      title: {
        type: String,
        default: '1'
      },
      isAdd: {
        type: Boolean,
        default: true
      },
      whereIs: {
        type: String,
        default: ''
      }
    },
    data() {
      return {
        isShow: false
      }
    },
    methods:{
      changeIsShow(){
        this.isShow = !this.isShow;
        this.$emit('feedback', this.title)
      }
    }
  }
</script>

<style type="text/scss" lang="scss" scoped>
  .fade-enter-active, .fade-leave-active {
    transition: opacity .2s;
  }

  .fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */
  {
    opacity: 0;
  }

  .rotate {
    transition: all .3s;
    transform: rotate(180deg);
  }

  .rotate-go {
    transition: all .3s;
    transform: rotate(0deg);
  }

  .fold_item {
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    .operation {
      line-height: 40px;
      padding: 0 20px;
      width: 100%;
      box-sizing: border-box;
      overflow: hidden;
      &::before {
        content: " ";
        background-color: #1CAAFE;
        width: 6px;
        height: 18px;
        float: left;
        margin: 14px 4px 0 0px; 
      }
      >div{
        box-sizing: border-box;
        border-bottom: 1px #ccc solid;
        overflow: hidden;
        line-height: 40px;
        .info-text {
          float: left;
          font-size:16px;
          margin-left: 5px;
          padding: 3px;
          color: black;
        }
        .add-icon,.icon {
          float: right;
          img {
            width: 18px;
          }
          margin-left: 20px;
        }
        .icon {
          img{
            margin-bottom: 6px;
          }
        }
      }

    }
  }
</style>
